import request from '@/utils/request'
import qs from 'qs'

export function add(data) {
  return request({
    url: 'api/factoryModel',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: 'api/factoryModel/',
    method: 'delete',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: 'api/factoryModel',
    method: 'put',
    data
  })
}

export function getModels(params) {
  return request({
    url: 'api/factoryModel?'+ qs.stringify(params, { indices: false }),
    method: 'get',
  })
}

export function list(params) {
  return request({
    url: 'api/factoryModel/list',
    method: 'get',
    params
  })
}

export function getFactoryModelTree(pid) {
  return request({
    url: 'api/factoryModel/lazy?pid=' + pid,
    method: 'get'
  })
}

export function getFactoryModelChild(id){
  return request({
    url: 'api/factoryModel/child?id=' + id,
    method: 'get'
  })
}

export function getTree(data) {
  return request({
    url: 'api/factoryModel/getTree',
    method: 'get',
    data
  })
}

export function getTreeNotDevice(data) {
  return request({
    url: 'api/factoryModel/getTreeNotDevice',
    method: 'get',
    data
  })
}

export function getTreeById(params) {
  return request({
    url: 'api/factoryModel/getTreeById',
    method: 'get',
    params
  })
}

//导入
export function importTree(data) {
  return request({
    url: 'api/factoryModel/importTree',
    method: 'post',
    data
  })
}

export function getCalendar(data) {
  return request({
    url: 'api/factoryModel/getCalendar',
    method: 'post',
    data
  })
}

export function getCondition(data) {
  return request({
    url: 'api/factoryModel/getCondition',
    method: 'post',
    data
  })
}

export default { add, edit, del , getTree, getTreeNotDevice, getModels ,list, getTreeById, importTree, getCalendar, getCondition}
